package com.example.demo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

@Configuration
public class AysncConfig {
	@Bean(name = "threadPoolTaskExecutor")    
	public ThreadPoolTaskExecutor getAsyncThreadPoolTaskExecutor() {        
		ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();        
		taskExecutor.setCorePoolSize(20);//基础的线程数        
		taskExecutor.setMaxPoolSize(200);//最大允许的线程数        
		taskExecutor.setQueueCapacity(25);//等待队列的长度        
		taskExecutor.setKeepAliveSeconds(60);//核心线程存活时间        
		taskExecutor.setThreadNamePrefix("stgbehavior-");        
		taskExecutor.initialize();        
		return taskExecutor;    
		}

}
